package cn.edu.sjtu.stap.cg;

import org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode;
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.InvocationSite;

public class CgCall extends CgEdge {
    private static final long serialVersionUID = 1L;

    public CgCall() {
        super();
    }

    public void setASTNode(ASTNode node) {
        if (node instanceof InvocationSite) {
            super.setASTNode(node);
        } else {
            throw new IllegalArgumentException("Uncompatible AST node!");
        }
    }
    
    // TODO Return a meaningful name.
    public String getCallName() {
        return astNode == null ? null : astNode.toString();
    }
    
    public String toString() {
        StringBuffer b = new StringBuffer();
        
        b.append("<Call Id: ");
        b.append(this.getId());
        //b.append(", Content:");
        //b.append(this.getCallName());
        b.append(", From: Node ");
        b.append(this.getSourceNode().getId());
        b.append(", To: Node ");
        b.append(this.getDestinationNode().getId());
        b.append(">");
        
        return b.toString();
    }
}
